#[derive(Debug)]
pub struct Ast<'a> {
    pub defs: Vec<TopDef<'a>>,
    pub exports: Vec<Sign<'a>>,
}

/// 尚未解析转义
#[derive(Debug)]
pub struct Str<'a>(pub &'a str);

#[derive(Debug)]
pub enum TopDef<'a> {
    ValFn {
        name: &'a str,
        params: Option<Vec<&'a str>>,
        val: Expr<'a>,
    },
    Import {
        from: Str<'a>,
        items: Vec<Sign<'a>>,
    },
}

#[derive(Debug)]
pub struct Sign<'a> {
    pub src_name: &'a str,
    pub out_name: Option<&'a str>,
    pub params: Option<usize>,
}

#[derive(Debug)]
pub enum Expr<'a> {
    String(Str<'a>),
    Tuple(Vec<Expr<'a>>),
    Use {
        name: &'a str,
        args: Option<Vec<Expr<'a>>>,
    },
    Let {
        pat: Pattern<'a>,
        val: Box<Expr<'a>>,
        then: Box<Expr<'a>>,
        alt: Option<Box<Expr<'a>>>,
    },
    Match {
        val: Box<Expr<'a>>,
        case: Vec<(Pattern<'a>, Expr<'a>)>,
    },
}

#[derive(Debug)]
pub enum Pattern<'a> {
    Wildcard,
    String(Str<'a>),
    Name(&'a str),
    Tuple(Vec<Pattern<'a>>),
}
